﻿using System.Collections.Generic;
using IDAL;
using Model;
using NHibernate;

namespace SqlDALLibrary
{
    public class SystemLogDal : ISystemLogDAL
    {
        private static EntityControl control;

        static SystemLogDal()
        {
            control = EntityControl.CreateEntityControl("Model");
        }

        public void saveSystemLog(SystemLog systemLog)
        {
            NHibernateHelper nh = new NHibernateHelper();
            ISession session = nh.GetSession();
            using (var tx = session.BeginTransaction())
            {
                session.Save(systemLog);
                tx.Commit();
            }
            session.Close();
        }

        public IList<SystemLog> getSystemLog()
        {
            NHibernateHelper nh = new NHibernateHelper();
            ISession session = nh.GetSession();
            IList<SystemLog> systemLogList = session.CreateQuery("from SystemLog")
                                                .List<SystemLog>();
            session.Close();
            return systemLogList;
        }

    }
}
